package thread.lock.reentral_condition_base;

/**
 * Created by mHandler on 2018/6/3 0003.
 * Description:condition中await()和signal()方法使用相当于object中wait和notify方法；
 */
public class MyThread extends Thread {
    private MyService myService;

    public MyThread(MyService myService){
        super();
        this.myService = myService;
    }

    @Override
    public void run() {
        super.run();
        myService.await();
    }

    public static void main(String[] args) {
        try {
            MyService myService = new MyService();
            MyThread thread = new MyThread(myService);
            thread.start();
            Thread.sleep(3000);
            myService.signal();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
